<?php include APP_PATH."application/views/head.html" ?>

<ol class="breadcrumb">
  <li><a href="/">主页</a></li>
  <li class="active">搜索页</li>
</ol>


<div class="container">
    <?php
    if(isset($items) && $items !=array()){
       foreach( $items as $i )
       {
       echo '
    <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
            <img src="/images/product/'.$i['product_uuid'].'.jpg" alt="zi">
            <div class="caption">
                <h3><a href="/item/get?name='.$i['product_uuid'].'">'.mb_substr($i['product_name'],0,12,"UTF-8").'</a></h3>
                <p>价格:<span class="price">'.$i['money'].'</span>元<p>
                <p><a href="/order/add?name='.$i['product_uuid'].'" class="btn btn-primary btn-sm" role="button">购买</a>
                <a href="/fav/add?name='.$i['product_uuid'].'" class="btn btn-sm btn-default" role="button">收藏</a>
                </p>
            </div>
        </div>
    </div>
       ';
       }
    }
    ?>

</div> <!-- /container -->

<div class="center">
    <ul class="nav nav-justified pagination pagination-lg">
       <?php
       if(isset($curPage)&&isset($curSize)&&isset($maxNum)){
           $pageAmount = intval($maxNum/$curSize);
           if ($maxNum%$curSize)
              $pageAmount++;

           if($curPage>1){
              echo '<li><a href="/item/search?name='.($product_name).'&page='.($curPage-1).'&size='.($curSize).'">&laquo;</a></li>';
           }

           for($i=1; $i<=$pageAmount; $i++){
               if($curPage==$i)
                  echo '<li><a class="selected" href="/item/search?name='.($product_name).'&page='.$i.'&size='.($curSize).'">'.$i.'</a></li>';
               else
                  echo '<li><a href="/item/search?name='.($product_name).'&page='.$i.'&size='.($curSize).'">'.$i.'</a></li>';
           }

           if($curPage<$pageAmount){
              echo '<li><a href="/item/search?name='.($product_name).'&page='.($curPage+1).'&size='.($curSize).'">&raquo;</a></li>';
           }
        }
        ?>
    </ul>
</div>


<?php include APP_PATH."application/views/foot.html" ?>
